# eric7.WebBrowser.WebBrowserTabWidget

Module implementing the central widget showing the web pages.

### Global Attributes

None

### Classes

WebBrowserTabWidget | Class implementing the central widget showing the web pages.

### Functions

None

## WebBrowserTabWidget

Class implementing the central widget showing the web pages.

### Signals

browserClosed(QWidget)
  emitted after a browser was closed
browserOpened(QWidget)
  emitted after a new browser was created
browserZoomValueChanged(int)
  emitted to signal a change of the current browser's zoom level
currentUrlChanged(QUrl)
  emitted after the URL of the current browser has changed
showMessage(str)
  emitted to show a message in the main window status bar
sourceChanged(WebBrowserView, QUrl)
  emitted after the URL of a browser has changed
titleChanged(WebBrowserView, str)
  emitted after the title of a browser has changed

### Derived from

EricTabWidget

### Class Attributes

None

### Class Methods

None

### Methods

WebBrowserTabWidget | Constructor
__aboutToShowClosedTabsMenu | Private slot to populate the closed tabs menu.
__closedTabAvailable | Private slot to handle changes of the availability of closed tabs.
__currentChanged | Private slot to handle an index change.
__elide | Private method to elide some text.
__guessUrlFromPath | Private method to guess an URL given a path string.
__iconChanged | Private slot to handle a change of the web site icon.
__initTabContextMenu | Private method to create the tab context menu.
__lineEditReturnPressed | Private slot to handle the entering of an URL.
__loadFinished | Private method to handle the loadFinished signal.
__loadProgress | Private method to handle the loadProgress signal.
__navigationMenuTriggered | Private slot called to handle the navigation button menu selection.
__newBrowser | Private slot to open a new browser tab.
__pathSelected | Private slot called when a URL is selected from the completer.
__recentlyAudibleChanged | Private slot to react on the audible state of a page.
__showContextMenu | Private slot to show the tab context menu.
__showNavigationMenu | Private slot to show the navigation button menu.
__sourceChanged | Private slot to handle a change of a browsers source.
__tabContextMenuAudioMute | Private method to mute or unmute the selected tab.
__tabContextMenuClone | Private method to clone the selected tab.
__tabContextMenuClose | Private method to close the selected tab.
__tabContextMenuCloseOthers | Private slot to close all other tabs.
__tabContextMenuMoveLeft | Private method to move a tab one position to the left.
__tabContextMenuMoveRight | Private method to move a tab one position to the right.
__tabContextMenuPrint | Private method to print the selected tab.
__tabContextMenuPrintPdf | Private method to print the selected tab as PDF.
__tabContextMenuPrintPreview | Private method to show a print preview of the selected tab.
__titleChanged | Private slot to handle a change of a browsers title.
__windowCloseRequested | Private slot to handle the windowCloseRequested signal of a browser.
browserAt | Public method to get a reference to the browser with the given index.
browsers | Public method to get a list of references to all browsers.
canRestoreClosedTab | Public method to check, if closed tabs can be restored.
clearClosedTabsList | Public slot to clear the list of closed tabs.
closeAllBrowsers | Public slot called to handle the close all action.
closeBrowser | Public slot called to handle the close action.
closeBrowserAt | Public slot to close a browser based on its index.
closeBrowserView | Public method to close the given browser.
closedTabsManager | Public slot to get a reference to the closed tabs manager.
currentBrowser | Public method to get a reference to the current browser.
currentUrlBar | Public method to get a reference to the current url bar.
getSessionData | Public method to populate the session data.
getSourceFileList | Public method to get a list of all opened Qt help files.
loadFromSessionData | Public method to load the session data.
newBrowser | Public method to create a new web browser tab.
newBrowserAfter | Public method to create a new web browser tab after a given one.
preferencesChanged | Public slot to handle a change of preferences.
printBrowser | Public slot called to print the displayed page.
printBrowserPdf | Public slot called to print the displayed page to PDF.
printPreviewBrowser | Public slot called to show a print preview of the displayed file.
reloadAllBrowsers | Public slot to reload all browsers.
restoreAllClosedTabs | Public slot to restore all closed tabs.
restoreClosedTab | Public slot to restore the most recently closed tab.
shallShutDown | Public method to check, if the application should be shut down.
stackedUrlBar | Public method to get a reference to the stacked url bar.
urlBarForView | Public method to get a reference to the UrlBar associated with the given view.

### Static Methods

None

#### WebBrowserTabWidget (Constructor)

WebBrowserTabWidget(parent)

Constructor

parent (QWidget)
  reference to the parent widget

#### WebBrowserTabWidget.__aboutToShowClosedTabsMenu

__aboutToShowClosedTabsMenu()

Private slot to populate the closed tabs menu.

#### WebBrowserTabWidget.__closedTabAvailable

__closedTabAvailable(avail)

Private slot to handle changes of the availability of closed tabs.

avail (bool)
  flag indicating the availability of closed tabs

#### WebBrowserTabWidget.__currentChanged

__currentChanged(index)

Private slot to handle an index change.

index (int)
  new index

#### WebBrowserTabWidget.__elide

__elide(txt, mode=Qt.TextElideMode.ElideRight, length=40)

Private method to elide some text.

txt (str)
  text to be elided
mode (Qt.TextElideMode)
  elide mode
length (int)
  amount of characters to be used

Return:
  the elided text

Return Type:
  str

#### WebBrowserTabWidget.__guessUrlFromPath

__guessUrlFromPath(path)

Private method to guess an URL given a path string.

path (str)
  path string to guess an URL for

Return:
  guessed URL

Return Type:
  QUrl

#### WebBrowserTabWidget.__iconChanged

__iconChanged(browser)

Private slot to handle a change of the web site icon.

browser (WebBrowserView)
  reference to the web browser

#### WebBrowserTabWidget.__initTabContextMenu

__initTabContextMenu()

Private method to create the tab context menu.

#### WebBrowserTabWidget.__lineEditReturnPressed

__lineEditReturnPressed(edit)

Private slot to handle the entering of an URL.

edit (UrlBar)
  reference to the line edit

#### WebBrowserTabWidget.__loadFinished

__loadFinished(ok, _browser)

Private method to handle the loadFinished signal.

ok (bool)
  flag indicating the result
_browser (WebBrowserView)
  reference to the web browser (unused)

#### WebBrowserTabWidget.__loadProgress

__loadProgress(progress, browser)

Private method to handle the loadProgress signal.

Note: This works around wegengine not sending a loadFinished signal for navigation on the same page.

progress (int)
  load progress in percent
browser (WebBrowserView)
  reference to the web browser

#### WebBrowserTabWidget.__navigationMenuTriggered

__navigationMenuTriggered(act)

Private slot called to handle the navigation button menu selection.

act (QAction)
  reference to the selected action

#### WebBrowserTabWidget.__newBrowser

__newBrowser()

Private slot to open a new browser tab.

#### WebBrowserTabWidget.__pathSelected

__pathSelected(path)

Private slot called when a URL is selected from the completer.

path (str)
  path to be shown

#### WebBrowserTabWidget.__recentlyAudibleChanged

__recentlyAudibleChanged(recentlyAudible, page)

Private slot to react on the audible state of a page.

recentlyAudible (bool)
  flag indicating the new audible state
page (WebBrowserPage)
  reference to the web page

#### WebBrowserTabWidget.__showContextMenu

__showContextMenu(coord, index)

Private slot to show the tab context menu.

coord (QPoint)
  the position of the mouse pointer
index (int)
  index of the tab the menu is requested for

#### WebBrowserTabWidget.__showNavigationMenu

__showNavigationMenu()

Private slot to show the navigation button menu.

#### WebBrowserTabWidget.__sourceChanged

__sourceChanged(url, browser)

Private slot to handle a change of a browsers source.

url (QUrl)
  URL of the new site
browser (WebBrowserView)
  reference to the web browser

#### WebBrowserTabWidget.__tabContextMenuAudioMute

__tabContextMenuAudioMute()

Private method to mute or unmute the selected tab.

#### WebBrowserTabWidget.__tabContextMenuClone

__tabContextMenuClone()

Private method to clone the selected tab.

#### WebBrowserTabWidget.__tabContextMenuClose

__tabContextMenuClose()

Private method to close the selected tab.

#### WebBrowserTabWidget.__tabContextMenuCloseOthers

__tabContextMenuCloseOthers()

Private slot to close all other tabs.

#### WebBrowserTabWidget.__tabContextMenuMoveLeft

__tabContextMenuMoveLeft()

Private method to move a tab one position to the left.

#### WebBrowserTabWidget.__tabContextMenuMoveRight

__tabContextMenuMoveRight()

Private method to move a tab one position to the right.

#### WebBrowserTabWidget.__tabContextMenuPrint

__tabContextMenuPrint()

Private method to print the selected tab.

#### WebBrowserTabWidget.__tabContextMenuPrintPdf

__tabContextMenuPrintPdf()

Private method to print the selected tab as PDF.

#### WebBrowserTabWidget.__tabContextMenuPrintPreview

__tabContextMenuPrintPreview()

Private method to show a print preview of the selected tab.

#### WebBrowserTabWidget.__titleChanged

__titleChanged(title, browser)

Private slot to handle a change of a browsers title.

title (str)
  new title
browser (WebBrowserView)
  reference to the web browser

#### WebBrowserTabWidget.__windowCloseRequested

__windowCloseRequested(page)

Private slot to handle the windowCloseRequested signal of a browser.

page (WebBrowserPage)
  reference to the web page

#### WebBrowserTabWidget.browserAt

browserAt(index)

Public method to get a reference to the browser with the given index.

index (int)
  index of the browser to get

Return:
  reference to the indexed browser

Return Type:
  WebBrowserView

#### WebBrowserTabWidget.browsers

browsers()

Public method to get a list of references to all browsers.

Return:
  list of references to browsers

Return Type:
  list of WebBrowserView

#### WebBrowserTabWidget.canRestoreClosedTab

canRestoreClosedTab()

Public method to check, if closed tabs can be restored.

Return:
  flag indicating that closed tabs can be restored

Return Type:
  bool

#### WebBrowserTabWidget.clearClosedTabsList

clearClosedTabsList()

Public slot to clear the list of closed tabs.

#### WebBrowserTabWidget.closeAllBrowsers

closeAllBrowsers(shutdown=False)

Public slot called to handle the close all action.

shutdown (bool)
  flag indicating a shutdown action

#### WebBrowserTabWidget.closeBrowser

closeBrowser()

Public slot called to handle the close action.

#### WebBrowserTabWidget.closeBrowserAt

closeBrowserAt(index, shutdown=False)

Public slot to close a browser based on its index.

index (int)
  index of browser to close
shutdown (bool)
  flag indicating a shutdown action

#### WebBrowserTabWidget.closeBrowserView

closeBrowserView(browser)

Public method to close the given browser.

browser (WebBrowserView)
  reference to the web browser view to be closed

#### WebBrowserTabWidget.closedTabsManager

closedTabsManager()

Public slot to get a reference to the closed tabs manager.

Return:
  reference to the closed tabs manager

Return Type:
  ClosedTabsManager

#### WebBrowserTabWidget.currentBrowser

currentBrowser()

Public method to get a reference to the current browser.

Return:
  reference to the current browser

Return Type:
  WebBrowserView

#### WebBrowserTabWidget.currentUrlBar

currentUrlBar()

Public method to get a reference to the current url bar.

Return:
  reference to the current url bar

Return Type:
  UrlBar

#### WebBrowserTabWidget.getSessionData

getSessionData()

Public method to populate the session data.

Return:
  dictionary containing the session data

Return Type:
  dict

#### WebBrowserTabWidget.getSourceFileList

getSourceFileList()

Public method to get a list of all opened Qt help files.

Return:
  dictionary with tab id as key and host/namespace as value

Return Type:
  dict

#### WebBrowserTabWidget.loadFromSessionData

loadFromSessionData(sessionData)

Public method to load the session data.

sessionData (dict)
  dictionary containing the session data as generated by getSessionData()

#### WebBrowserTabWidget.newBrowser

newBrowser(link=None, position=-1, background=False, restoreSession=False)

Public method to create a new web browser tab.

link (str or QUrl)
  link to be shown
position (int)
  position to create the new tab at or -1 to add it to the end
background (bool)
  flag indicating to open the tab in the background
restoreSession (bool)
  flag indicating a restore session action

Return:
  reference to the new browser

Return Type:
  WebBrowserView

#### WebBrowserTabWidget.newBrowserAfter

newBrowserAfter(browser, link=None, background=False)

Public method to create a new web browser tab after a given one.

browser (WebBrowserView)
  reference to the browser to add after
link (str or QUrl)
  link to be shown
background (bool)
  flag indicating to open the tab in the background

Return:
  reference to the new browser

Return Type:
  WebBrowserView

#### WebBrowserTabWidget.preferencesChanged

preferencesChanged()

Public slot to handle a change of preferences.

#### WebBrowserTabWidget.printBrowser

printBrowser(browser=None)

Public slot called to print the displayed page.

browser (WebBrowserView)
  reference to the browser to be printed

#### WebBrowserTabWidget.printBrowserPdf

printBrowserPdf(browser=None)

Public slot called to print the displayed page to PDF.

browser (WebBrowserView)
  reference to the browser to be printed

#### WebBrowserTabWidget.printPreviewBrowser

printPreviewBrowser(browser=None)

Public slot called to show a print preview of the displayed file.

browser (WebBrowserView)
  reference to the browser to be printed

#### WebBrowserTabWidget.reloadAllBrowsers

reloadAllBrowsers()

Public slot to reload all browsers.

#### WebBrowserTabWidget.restoreAllClosedTabs

restoreAllClosedTabs()

Public slot to restore all closed tabs.

#### WebBrowserTabWidget.restoreClosedTab

restoreClosedTab(act)

Public slot to restore the most recently closed tab.

act (QAction)
  reference to the action that triggered

#### WebBrowserTabWidget.shallShutDown

shallShutDown()

Public method to check, if the application should be shut down.

Return:
  flag indicating a shut down

Return Type:
  bool

#### WebBrowserTabWidget.stackedUrlBar

stackedUrlBar()

Public method to get a reference to the stacked url bar.

Return:
  reference to the stacked url bar

Return Type:
  StackedUrlBar

#### WebBrowserTabWidget.urlBarForView

urlBarForView(view)

Public method to get a reference to the UrlBar associated with the given view.

view (WebBrowserView)
  reference to the view to get the urlbar for

Return:
  reference to the associated urlbar

Return Type:
  UrlBar

Up